// index.js
// 获取应用实例
const app = getApp()
Page({
  data: {
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad (options) {
    wx.setNavigationBarTitle({
      title: '泛微产品体验',
    })

    wx.login({
      success (res) {
        if (res.code) {
          wx.request({
            url: 'https://achievement.e-cology.com.cn/democenter/authorize.jsp',
            method: 'GET',
            data: {
              id:options.id,
              key: options.key,
              status: '2',
              code: res.code
            },
            header: {
              'content-type': 'application/json' // 默认值
            },
            success (res) {
              if (res.data && res.data.data) {
                that.setData({openId: res.data.data, phoneStatus:res.data.phoneStatus })
              }
            }
          })

        } else {
          
        }
      }
    })
  },

  cancel () {
    wx.reLaunch({
      url: '/pages/index/index'
    })
  },
  getPhoneNumber () {
    wx.scanCode({
      onlyFromCamera: true,// 只允许从相机扫码
      success(res){
        if (res.path) {
          wx.reLaunch({
            url: `/${res.path}`
          })
        }
      },
      fail (err) {
        wx.showToast({
          title:'扫描失败',
          icon: 'none',
          duration: 1000
        })
      }
    })
  },
})